﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace ALEXBlog.IRepository.Base
{
    public interface IBaseRepository
    {
        //增
        Task<int> AddAsync<TEntity>(params TEntity[] models) where TEntity : class, new();

        //删
        Task<int> RemoveAsync<TEntity>(params TEntity[] model) where TEntity : class, new();
        Task<int> RemoveAsync<TEntity>(object id) where TEntity : class, new();
        Task<int> RemoveAsync<TEntity>(params object[] ids) where TEntity : class, new();

        //改
        Task<int> UpdateAsync<TEntity>(params TEntity[] models) where TEntity : class, new();

        //查
        Task<TEntity> FindAsync<TEntity>(Expression<Func<TEntity, bool>> whereExpression) where TEntity : class, new(); //单例查询
        Task<List<TEntity>> QueryAsync<TEntity>() where TEntity : class, new(); //查询所有
        Task<List<TEntity>> QueryAsync<TEntity>(Expression<Func<TEntity, bool>> whereExpression) where TEntity : class, new(); //条件查询
        Task<List<TEntity>> QueryAsync<TEntity>(int pageIndex, int pageSize, Expression<Func<TEntity, bool>> whereExpression) where TEntity : class, new(); //分页条件查询
    }
}
